import 'package:lcapp/data/user_data_entity.dart';
import 'package:lcapp/data/jy_address_entity.dart';

userDataEntityFromJson(UserDataEntity data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['vip'] != null) {
		data.vip = json['vip'] is String
				? int.tryParse(json['vip'])
				: json['vip'].toInt();
	}
	if (json['card'] != null) {
		data.card = json['card'] is String
				? int.tryParse(json['card'])
				: json['card'].toInt();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['img'] != null) {
		data.img = json['img'].toString();
	}
	if (json['password'] != null) {
		data.password = json['password'].toString();
	}
	if (json['weixinpicture'] != null) {
		data.weixinpicture = json['weixinpicture'].toString();
	}
	if (json['profiles'] != null) {
		data.profiles = json['profiles'].toString();
	}
	if (json['address'] != null) {
		data.address = JyAddressEntity().fromJson(json['address']);
	}
	if (json['grainid'] != null) {
		data.grainid = json['grainid'].toString();
	}
	if (json['company'] != null) {
		data.company = json['company'].toString();
	}
	if (json['phone'] != null) {
		data.phone = json['phone'].toString();
	}
	if (json['realName'] != null) {
		data.realName = json['realName'].toString();
	}
	if (json['id_card'] != null) {
		data.id_card = json['id_card'].toString();
	}
	if (json['balances'] != null) {
		data.balances = json['balances'].toString();
	}
	if (json['invite'] != null) {
		data.invite = json['invite'].toString();
	}
	if (json['inviter'] != null) {
		data.inviter = json['inviter'].toString();
	}
	if (json['gold'] != null) {
		data.gold = json['gold'].toString();
	}
	if (json['cash'] != null) {
		data.cash = json['cash'].toString();
	}
	if (json['token'] != null) {
		data.token = json['token'].toString();
	}
	if (json['userstate'] != null) {
		data.userstate = json['userstate'] is String
				? int.tryParse(json['userstate'])
				: json['userstate'].toInt();
	}
	if (json['sex'] != null) {
		data.sex = json['sex'] is String
				? int.tryParse(json['sex'])
				: json['sex'].toInt();
	}
	if (json['vipEnd'] != null) {
		data.vipEnd = json['vipEnd'] is String
				? int.tryParse(json['vipEnd'])
				: json['vipEnd'].toInt();
	}
	if (json['like'] != null) {
		data.like = json['like'] is String
				? int.tryParse(json['like'])
				: json['like'].toInt();
	}
	if (json['fans'] != null) {
		data.fans = json['fans'] is String
				? int.tryParse(json['fans'])
				: json['fans'].toInt();
	}
	if (json['attention'] != null) {
		data.attention = json['attention'] is String
				? int.tryParse(json['attention'])
				: json['attention'].toInt();
	}
	if (json['attentionState'] != null) {
		data.attentionState = json['attentionState'] is String
				? int.tryParse(json['attentionState'])
				: json['attentionState'].toInt();
	}
	if (json['ocrInfo'] != null) {
		data.ocrInfo = OcrEntity().fromJson(json['ocrInfo']);
	}
	if (json['defaultName'] != null) {
		data.defaultName = json['defaultName'].toString();
	}
	if (json['addressRegin'] != null) {
		data.addressRegin = json['addressRegin'].toString();
	}
	if (json['addressDetail'] != null) {
		data.addressDetail = json['addressDetail'].toString();
	}
	if (json['coordinate'] != null) {
		data.coordinate = json['coordinate'].toString();
	}
	if (json['region'] != null) {
		data.region = json['region'].toString();
	}
	if (json['isLike'] != null) {
		data.isLike = json['isLike'] is String
				? int.tryParse(json['isLike'])
				: json['isLike'].toInt();
	}
	return data;
}

Map<String, dynamic> userDataEntityToJson(UserDataEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['vip'] = entity.vip;
	data['card'] = entity.card;
	data['name'] = entity.name;
	data['img'] = entity.img;
	data['password'] = entity.password;
	data['weixinpicture'] = entity.weixinpicture;
	data['profiles'] = entity.profiles;
	data['address'] = entity.address?.toJson();
	data['grainid'] = entity.grainid;
	data['company'] = entity.company;
	data['phone'] = entity.phone;
	data['realName'] = entity.realName;
	data['id_card'] = entity.id_card;
	data['balances'] = entity.balances;
	data['invite'] = entity.invite;
	data['inviter'] = entity.inviter;
	data['gold'] = entity.gold;
	data['cash'] = entity.cash;
	data['token'] = entity.token;
	data['userstate'] = entity.userstate;
	data['sex'] = entity.sex;
	data['vipEnd'] = entity.vipEnd;
	data['like'] = entity.like;
	data['fans'] = entity.fans;
	data['attention'] = entity.attention;
	data['attentionState'] = entity.attentionState;
	data['ocrInfo'] = entity.ocrInfo?.toJson();
	data['defaultName'] = entity.defaultName;
	data['addressRegin'] = entity.addressRegin;
	data['addressDetail'] = entity.addressDetail;
	data['coordinate'] = entity.coordinate;
	data['region'] = entity.region;
	data['isLike'] = entity.isLike;
	return data;
}

ocrEntityFromJson(OcrEntity data, Map<String, dynamic> json) {
	if (json['userName'] != null) {
		data.userName = json['userName'].toString();
	}
	if (json['idType'] != null) {
		data.idType = json['idType'].toString();
	}
	if (json['idNumber'] != null) {
		data.idNumber = json['idNumber'].toString();
	}
	return data;
}

Map<String, dynamic> ocrEntityToJson(OcrEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['userName'] = entity.userName;
	data['idType'] = entity.idType;
	data['idNumber'] = entity.idNumber;
	return data;
}